﻿///////////////////////////////////////////////////////////////
// This is generated code. If you modify this code, be aware
// of the fact that when you re-generate the code, your changes
// are lost. If you want to keep your changes, make this file read-only
// when you have finished your changes, however it is recommended that
// you inherit from this class to extend the functionality of this generated
// class or you modify / extend the templates used to generate this code.
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 1.0.2005.1
// Code is generated on: October 21, 2008 12:02:13 AM
// Code is generated using templates: C# template set for SqlServer (1.0.2005.1)
// Templates vendor: Solutions Design.
// Templates version: 1.0.2005.1.111705
//////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections;
using System.Runtime.Serialization;
using System.Data;
using System.Xml.Serialization;

using Ultimate.DAL;
using Ultimate.DAL.FactoryClasses;
using Ultimate.DAL.DaoClasses;
using Ultimate.DAL.RelationClasses;
using Ultimate.DAL.ValidatorClasses;
using Ultimate.DAL.HelperClasses;
using Ultimate.DAL.CollectionClasses;

using SD.LLBLGen.Pro.ORMSupportClasses;

namespace Ultimate.DAL.EntityClasses
{
	
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END
	/// <summary>Entity base class which represents the base class for the entity 'Game'.<br/><br/>
	/// 
	/// </summary>
	[Serializable]
	public abstract partial class GameEntityBase : EntityBase, ISerializable
		// __LLBLGENPRO_USER_CODE_REGION_START AdditionalInterfaces
		// __LLBLGENPRO_USER_CODE_REGION_END	
	{
		#region Class Member Declarations


		private FieldEntity _field;
		private bool	_alwaysFetchField, _alreadyFetchedField, _fieldReturnsNewIfNotFound;
		private LeagueEntity _league;
		private bool	_alwaysFetchLeague, _alreadyFetchedLeague, _leagueReturnsNewIfNotFound;
		private TeamEntity _team;
		private bool	_alwaysFetchTeam, _alreadyFetchedTeam, _teamReturnsNewIfNotFound;
		private TeamEntity _team_;
		private bool	_alwaysFetchTeam_, _alreadyFetchedTeam_, _team_ReturnsNewIfNotFound;

		private static Hashtable	_customProperties;
		private static Hashtable	_fieldsCustomProperties;
		
		// __LLBLGENPRO_USER_CODE_REGION_START PrivateMembers
		// __LLBLGENPRO_USER_CODE_REGION_END
		#endregion

		#region DataBinding Change Event Handler Declarations
		/// <summary>Event which is thrown when GameID changes value. Databinding related.</summary>
		public event EventHandler GameIDChanged;
		/// <summary>Event which is thrown when LeagueID changes value. Databinding related.</summary>
		public event EventHandler LeagueIDChanged;
		/// <summary>Event which is thrown when FieldID changes value. Databinding related.</summary>
		public event EventHandler FieldIDChanged;
		/// <summary>Event which is thrown when GameDay changes value. Databinding related.</summary>
		public event EventHandler GameDayChanged;
		/// <summary>Event which is thrown when HomeTeamID changes value. Databinding related.</summary>
		public event EventHandler HomeTeamIDChanged;
		/// <summary>Event which is thrown when AwayTeamID changes value. Databinding related.</summary>
		public event EventHandler AwayTeamIDChanged;
		/// <summary>Event which is thrown when HomeHomeScore changes value. Databinding related.</summary>
		public event EventHandler HomeHomeScoreChanged;
		/// <summary>Event which is thrown when HomeAwayScore changes value. Databinding related.</summary>
		public event EventHandler HomeAwayScoreChanged;
		/// <summary>Event which is thrown when AwayHomeScore changes value. Databinding related.</summary>
		public event EventHandler AwayHomeScoreChanged;
		/// <summary>Event which is thrown when AwayAwayScore changes value. Databinding related.</summary>
		public event EventHandler AwayAwayScoreChanged;
		/// <summary>Event which is thrown when HomeSpiritScore changes value. Databinding related.</summary>
		public event EventHandler HomeSpiritScoreChanged;
		/// <summary>Event which is thrown when AwaySpiritScore changes value. Databinding related.</summary>
		public event EventHandler AwaySpiritScoreChanged;
		/// <summary>Event which is thrown when HomeWharmbyPlayerID changes value. Databinding related.</summary>
		public event EventHandler HomeWharmbyPlayerIDChanged;
		/// <summary>Event which is thrown when AwayWharmbyPlayerID changes value. Databinding related.</summary>
		public event EventHandler AwayWharmbyPlayerIDChanged;
		/// <summary>Event which is thrown when Description changes value. Databinding related.</summary>
		public event EventHandler DescriptionChanged;
		/// <summary>Event which is thrown when EnteredByID changes value. Databinding related.</summary>
		public event EventHandler EnteredByIDChanged;
		/// <summary>Event which is thrown when ChangedByID changes value. Databinding related.</summary>
		public event EventHandler ChangedByIDChanged;
		/// <summary>Event which is thrown when GameTime changes value. Databinding related.</summary>
		public event EventHandler GameTimeChanged;
		/// <summary>Event which is thrown when Grouping changes value. Databinding related.</summary>
		public event EventHandler GroupingChanged;

		#endregion
		
		/// <summary>Static CTor for setting up custom property hashtables. Is executed before the first instance of this entity class or derived classes is constructed. </summary>
		static GameEntityBase()
		{
			SetupCustomPropertyHashtables();
		}

		/// <summary>CTor</summary>
		public GameEntityBase()
		{
			InitClassEmpty(new PropertyDescriptorFactory(), CreateEntityFactoryInstance(), CreateValidator());
		}

	
		/// <summary>CTor</summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		public GameEntityBase(System.Int32 gameID)
		{
			InitClassFetch(gameID, CreateValidator(), new PropertyDescriptorFactory(), CreateEntityFactoryInstance(), null);
		}

		/// <summary>CTor</summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		public GameEntityBase(System.Int32 gameID, IPrefetchPath prefetchPathToUse)
		{
			InitClassFetch(gameID, CreateValidator(), new PropertyDescriptorFactory(), CreateEntityFactoryInstance(), prefetchPathToUse);
		}

		/// <summary>CTor</summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		/// <param name="validator">The custom validator object for this GameEntity</param>
		public GameEntityBase(System.Int32 gameID, GameValidator validator)
		{
			InitClassFetch(gameID, validator, new PropertyDescriptorFactory(), CreateEntityFactoryInstance(), null);
		}

		/// <summary>CTor</summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		/// <param name="validator">The custom validator object for this GameEntity</param>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		public GameEntityBase(System.Int32 gameID, GameValidator validator, IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse)
		{
			InitClassFetch(gameID, validator, propertyDescriptorFactoryToUse, entityFactoryToUse, null);
		}
	

		/// <summary>CTor</summary>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		public GameEntityBase(IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse)
		{
			InitClassEmpty(propertyDescriptorFactoryToUse, entityFactoryToUse, CreateValidator());
		}

		/// <summary>Protected CTor for deserialization</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		protected GameEntityBase(SerializationInfo info, StreamingContext context) : base(info, context)
		{


			_field = (FieldEntity)info.GetValue("_field", typeof(FieldEntity));
			if(_field!=null)
			{
				_field.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_fieldReturnsNewIfNotFound = info.GetBoolean("_fieldReturnsNewIfNotFound");
			_alwaysFetchField = info.GetBoolean("_alwaysFetchField");
			_alreadyFetchedField = info.GetBoolean("_alreadyFetchedField");
			_league = (LeagueEntity)info.GetValue("_league", typeof(LeagueEntity));
			if(_league!=null)
			{
				_league.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_leagueReturnsNewIfNotFound = info.GetBoolean("_leagueReturnsNewIfNotFound");
			_alwaysFetchLeague = info.GetBoolean("_alwaysFetchLeague");
			_alreadyFetchedLeague = info.GetBoolean("_alreadyFetchedLeague");
			_team = (TeamEntity)info.GetValue("_team", typeof(TeamEntity));
			if(_team!=null)
			{
				_team.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_teamReturnsNewIfNotFound = info.GetBoolean("_teamReturnsNewIfNotFound");
			_alwaysFetchTeam = info.GetBoolean("_alwaysFetchTeam");
			_alreadyFetchedTeam = info.GetBoolean("_alreadyFetchedTeam");
			_team_ = (TeamEntity)info.GetValue("_team_", typeof(TeamEntity));
			if(_team_!=null)
			{
				_team_.AfterSave+=new EventHandler(OnEntityAfterSave);
			}
			_team_ReturnsNewIfNotFound = info.GetBoolean("_team_ReturnsNewIfNotFound");
			_alwaysFetchTeam_ = info.GetBoolean("_alwaysFetchTeam_");
			_alreadyFetchedTeam_ = info.GetBoolean("_alreadyFetchedTeam_");

			
			// __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
			// __LLBLGENPRO_USER_CODE_REGION_END
		}

		
		/// <summary> Will perform post-ReadXml actions as well as the normal ReadXml() actions, performed by the base class.</summary>
		/// <param name="node">XmlNode with Xml data which should be read into this entity and its members. Node's root element is the root element of the entity's Xml data</param>
		public override void ReadXml(System.Xml.XmlNode node)
		{
			base.ReadXml (node);


			_alreadyFetchedField = (_field != null);
			_alreadyFetchedLeague = (_league != null);
			_alreadyFetchedTeam = (_team != null);
			_alreadyFetchedTeam_ = (_team_ != null);

		}


		/// <summary> Saves the Entity class to the persistent storage. It updates or inserts the entity, which depends if the entity was originally read from the 
		/// database. If the entity is new, an insert is done and the updateRestriction is ignored. If the entity is not new, the updateRestriction
		/// predicate is used to create an additional where clause (it will be added with AND) for the update query. This predicate can be used for
		/// concurrency checks, like checks on timestamp column values.</summary>
		/// <param name="updateRestriction">Predicate expression, meant for concurrency checks in an Update query. Will be ignored when the entity is new </param>
		/// <param name="recurse">When true, it will save all dirty objects referenced (directly or indirectly) by this entity also.</param>
		/// <returns>true if Save succeeded, false otherwise</returns>
		/// <remarks>Do not call this routine directly, use the overloaded version in a derived class as this version doesn't construct a
		/// local transaction during recursive save, this is done in the overloaded version in a derived class.</remarks>
		/// <exception cref="ORMQueryExecutionException">When an exception is caught during the save process. The caught exception is set as the
		/// inner exception. Encapsulation of database-related exceptions is necessary since these exceptions do not have a common exception framework implemented.</exception>
		public override bool Save(IPredicate updateRestriction, bool recurse)
		{
			bool transactionStartedInThisScope = false;
			Transaction transactionManager = null;

			if(recurse || ((this.LLBLGenProIsInHierarchyOfType==InheritanceHierarchyType.TargetPerEntity) && this.LLBLGenProIsSubType))
			{
				if(!base.ParticipatesInTransaction)
				{
					transactionManager = new Transaction(IsolationLevel.ReadCommitted, "SaveRecursively");
					transactionManager.Add(this);
					transactionStartedInThisScope=true;
				}
			}
			try
			{
				bool result = base.Save(updateRestriction, recurse);
				if(transactionStartedInThisScope)
				{
					transactionManager.Commit();
				}
				return result;
			}
			catch
			{
				if(transactionStartedInThisScope)
				{
					transactionManager.Rollback();
				}
				throw;
			}
			finally
			{
				if(transactionStartedInThisScope)
				{
					transactionManager.Dispose();
				}
			}
		}
		


		/// <summary> ISerializable member. Does custom serialization so event handlers do not get serialized.
		/// Serializes members of this entity class and uses the base class' implementation to serialize the rest.</summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void GetObjectData(SerializationInfo info, StreamingContext context)
		{


			info.AddValue("_field", _field);
			info.AddValue("_fieldReturnsNewIfNotFound", _fieldReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchField", _alwaysFetchField);
			info.AddValue("_alreadyFetchedField", _alreadyFetchedField);
			info.AddValue("_league", _league);
			info.AddValue("_leagueReturnsNewIfNotFound", _leagueReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchLeague", _alwaysFetchLeague);
			info.AddValue("_alreadyFetchedLeague", _alreadyFetchedLeague);
			info.AddValue("_team", _team);
			info.AddValue("_teamReturnsNewIfNotFound", _teamReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchTeam", _alwaysFetchTeam);
			info.AddValue("_alreadyFetchedTeam", _alreadyFetchedTeam);
			info.AddValue("_team_", _team_);
			info.AddValue("_team_ReturnsNewIfNotFound", _team_ReturnsNewIfNotFound);
			info.AddValue("_alwaysFetchTeam_", _alwaysFetchTeam_);
			info.AddValue("_alreadyFetchedTeam_", _alreadyFetchedTeam_);

			
			// __LLBLGENPRO_USER_CODE_REGION_START GetObjectInfo
			// __LLBLGENPRO_USER_CODE_REGION_END
			base.GetObjectData(info, context);
		}
		
		/// <summary> Sets the related entity property to the entity specified. If the property is a collection, it will add the entity specified to that collection.</summary>
		/// <param name="propertyName">Name of the property.</param>
		/// <param name="entity">Entity to set as an related entity</param>
		/// <remarks>Used by prefetch path logic.</remarks>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntityProperty(string propertyName, IEntityCore entity)
		{
			switch(propertyName)
			{
				case "Field":
					_alreadyFetchedField = true;
					this.Field = (FieldEntity)entity;
					break;
				case "League":
					_alreadyFetchedLeague = true;
					this.League = (LeagueEntity)entity;
					break;
				case "Team":
					_alreadyFetchedTeam = true;
					this.Team = (TeamEntity)entity;
					break;
				case "Team_":
					_alreadyFetchedTeam_ = true;
					this.Team_ = (TeamEntity)entity;
					break;



				default:

					break;
			}
		}

		/// <summary> Sets the internal parameter related to the fieldname passed to the instance relatedEntity. </summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void SetRelatedEntity(IEntity relatedEntity, string fieldName)
		{
			switch(fieldName)
			{
				case "Field":
					SetupSyncField(relatedEntity);
					break;
				case "League":
					SetupSyncLeague(relatedEntity);
					break;
				case "Team":
					SetupSyncTeam(relatedEntity);
					break;
				case "Team_":
					SetupSyncTeam_(relatedEntity);
					break;


				default:

					break;
			}
		}
		
		/// <summary> Unsets the internal parameter related to the fieldname passed to the instance relatedEntity. Reverses the actions taken by SetRelatedEntity() </summary>
		/// <param name="relatedEntity">Instance to unset as the related entity of type entityType</param>
		/// <param name="fieldName">Name of field mapped onto the relation which resolves in the instance relatedEntity</param>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override void UnsetRelatedEntity(IEntity relatedEntity, string fieldName)
		{
			switch(fieldName)
			{
				case "Field":
					DesetupSyncField(false);
					break;
				case "League":
					DesetupSyncLeague(false);
					break;
				case "Team":
					DesetupSyncTeam(false);
					break;
				case "Team_":
					DesetupSyncTeam_(false);
					break;


				default:

					break;
			}
		}

		/// <summary> Gets a collection of related entities referenced by this entity which depend on this entity (this entity is the PK side of their FK fields). These
		/// entities will have to be persisted after this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override ArrayList GetDependingRelatedEntities()
		{
			ArrayList toReturn = new ArrayList();


			return toReturn;
		}
		
		/// <summary> Gets a collection of related entities referenced by this entity which this entity depends on (this entity is the FK side of their PK fields). These
		/// entities will have to be persisted before this entity during a recursive save.</summary>
		/// <returns>Collection with 0 or more IEntity objects, referenced by this entity</returns>
		public override ArrayList GetDependentRelatedEntities()
		{
			ArrayList toReturn = new ArrayList();
			if(_field!=null)
			{
				toReturn.Add(_field);
			}
			if(_league!=null)
			{
				toReturn.Add(_league);
			}
			if(_team!=null)
			{
				toReturn.Add(_team);
			}
			if(_team_!=null)
			{
				toReturn.Add(_team_);
			}


			return toReturn;
		}
		
		/// <summary> Gets an ArrayList of all entity collections stored as member variables in this entity. The contents of the ArrayList is
		/// used by the DataAccessAdapter to perform recursive saves. Only 1:n related collections are returned.</summary>
		/// <returns>Collection with 0 or more IEntityCollection objects, referenced by this entity</returns>
		public override ArrayList GetMemberEntityCollections()
		{
			ArrayList toReturn = new ArrayList();


			return toReturn;
		}

		

		

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 gameID)
		{
			return FetchUsingPK(gameID, null, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 gameID, IPrefetchPath prefetchPathToUse)
		{
			return FetchUsingPK(gameID, prefetchPathToUse, null);
		}

		/// <summary> Fetches the contents of this entity from the persistent storage using the primary key.</summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <returns>True if succeeded, false otherwise.</returns>
		public bool FetchUsingPK(System.Int32 gameID, IPrefetchPath prefetchPathToUse, Context contextToUse)
		{
			return Fetch(gameID, prefetchPathToUse, contextToUse);
		}

		/// <summary> Refetches the Entity from the persistent storage. Refetch is used to re-load an Entity which is marked "Out-of-sync", due to a save action. 
		/// Refetching an empty Entity has no effect. </summary>
		/// <returns>true if Refetch succeeded, false otherwise</returns>
		public override bool Refetch()
		{
			return Fetch(this.GameID, null, null);
		}


		/// <summary> Deletes the Entity from the persistent storage. This method succeeds also when the Entity is not present.</summary>
		/// <param name="deleteRestriction">Predicate expression, meant for concurrency checks in a delete query. Overrules the predicate returned by a set ConcurrencyPredicateFactory object.</param>
		/// <returns>true if Delete succeeded, false otherwise</returns>
		public override bool Delete(IPredicate deleteRestriction)
		{
			bool transactionStartedInThisScope = false;
			Transaction transactionManager = null;
			if((this.LLBLGenProIsInHierarchyOfType==InheritanceHierarchyType.TargetPerEntity) && this.LLBLGenProIsSubType)
			{
				if(!base.ParticipatesInTransaction)
				{
					transactionManager = new Transaction(IsolationLevel.ReadCommitted, "DeleteEntity");
					transactionManager.Add(this);
					transactionStartedInThisScope=true;
				}
			}
			try
			{
				OnDelete();
				IDao dao = CreateDAOInstance();
				bool wasSuccesful = dao.DeleteExisting(base.Fields, base.Transaction, deleteRestriction);
				if(wasSuccesful)
				{
					base.Delete(deleteRestriction);
				}
				if(transactionStartedInThisScope)
				{
					transactionManager.Commit();
				}
				return wasSuccesful;
			}
			catch
			{
				if(transactionStartedInThisScope)
				{
					transactionManager.Rollback();
				}
				throw;
			}
			finally
			{
				if(transactionStartedInThisScope)
				{
					transactionManager.Dispose();
				}
				OnDeleteComplete();
			}
		}

		/// <summary> Returns true if the original value for the field with the fieldIndex passed in, read from the persistent storage was NULL, false otherwise.
		/// Should not be used for testing if the current value is NULL, use <see cref="TestCurrentFieldValueForNull"/> for that.</summary>
		/// <param name="fieldIndex">Index of the field to test if that field was NULL in the persistent storage</param>
		/// <returns>true if the field with the passed in index was NULL in the persistent storage, false otherwise</returns>
		public bool TestOriginalFieldValueForNull(GameFieldIndex fieldIndex)
		{
			return base.Fields[(int)fieldIndex].IsNull;
		}
		
		/// <summary>Returns true if the current value for the field with the fieldIndex passed in represents null/not defined, false otherwise.
		/// Should not be used for testing if the original value (read from the db) is NULL</summary>
		/// <param name="fieldIndex">Index of the field to test if its currentvalue is null/undefined</param>
		/// <returns>true if the field's value isn't defined yet, false otherwise</returns>
		public bool TestCurrentFieldValueForNull(GameFieldIndex fieldIndex)
		{
			return base.CheckIfCurrentFieldValueIsNull((int)fieldIndex);
		}
		
		/// <summary>Determines whether this entity is a subType of the entity represented by the passed in enum value, which represents a value in the EntityType enum</summary>
		/// <param name="typeOfEntity">Type of entity.</param>
		/// <returns>true if the passed in type is a supertype of this entity, otherwise false</returns>
		[EditorBrowsable(EditorBrowsableState.Never)]
		public override bool CheckIfIsSubTypeOf(int typeOfEntity)
		{
			return InheritanceInfoProviderSingleton.GetInstance().CheckIfIsSubTypeOf("GameEntity", ((Ultimate.DAL.EntityType)typeOfEntity).ToString());
		}




		/// <summary> Retrieves the related entity of type 'FieldEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'FieldEntity' which is related to this entity.</returns>
		public FieldEntity GetSingleField()
		{
			return GetSingleField(false);
		}

		/// <summary> Retrieves the related entity of type 'FieldEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'FieldEntity' which is related to this entity.</returns>
		public virtual FieldEntity GetSingleField(bool forceFetch)
		{
 			if( ( !_alreadyFetchedField || forceFetch || _alwaysFetchField) && !base.IsSerializing && !base.IsDeserializing )
			{

				FieldEntity newEntity = new FieldEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = newEntity.FetchUsingPK(this.FieldID);
				if(!_fieldReturnsNewIfNotFound && !fetchResult)
				{
					this.Field = null;
				}
				else
				{
					if((base.ActiveContext!=null)&&fetchResult)
					{
						newEntity = (FieldEntity)base.ActiveContext.Get(newEntity);
					}
					this.Field = newEntity;
					_alreadyFetchedField = fetchResult;
				}
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _field;
		}

		/// <summary> Retrieves the related entity of type 'LeagueEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'LeagueEntity' which is related to this entity.</returns>
		public LeagueEntity GetSingleLeague()
		{
			return GetSingleLeague(false);
		}

		/// <summary> Retrieves the related entity of type 'LeagueEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'LeagueEntity' which is related to this entity.</returns>
		public virtual LeagueEntity GetSingleLeague(bool forceFetch)
		{
 			if( ( !_alreadyFetchedLeague || forceFetch || _alwaysFetchLeague) && !base.IsSerializing && !base.IsDeserializing )
			{

				LeagueEntity newEntity = new LeagueEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = newEntity.FetchUsingPK(this.LeagueID);
				if(!_leagueReturnsNewIfNotFound && !fetchResult)
				{
					this.League = null;
				}
				else
				{
					if((base.ActiveContext!=null)&&fetchResult)
					{
						newEntity = (LeagueEntity)base.ActiveContext.Get(newEntity);
					}
					this.League = newEntity;
					_alreadyFetchedLeague = fetchResult;
				}
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _league;
		}

		/// <summary> Retrieves the related entity of type 'TeamEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'TeamEntity' which is related to this entity.</returns>
		public TeamEntity GetSingleTeam()
		{
			return GetSingleTeam(false);
		}

		/// <summary> Retrieves the related entity of type 'TeamEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'TeamEntity' which is related to this entity.</returns>
		public virtual TeamEntity GetSingleTeam(bool forceFetch)
		{
 			if( ( !_alreadyFetchedTeam || forceFetch || _alwaysFetchTeam) && !base.IsSerializing && !base.IsDeserializing )
			{

				TeamEntity newEntity = new TeamEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = newEntity.FetchUsingPK(this.HomeTeamID);
				if(!_teamReturnsNewIfNotFound && !fetchResult)
				{
					this.Team = null;
				}
				else
				{
					if((base.ActiveContext!=null)&&fetchResult)
					{
						newEntity = (TeamEntity)base.ActiveContext.Get(newEntity);
					}
					this.Team = newEntity;
					_alreadyFetchedTeam = fetchResult;
				}
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _team;
		}

		/// <summary> Retrieves the related entity of type 'TeamEntity', using a relation of type 'n:1'</summary>
		/// <returns>A fetched entity of type 'TeamEntity' which is related to this entity.</returns>
		public TeamEntity GetSingleTeam_()
		{
			return GetSingleTeam_(false);
		}

		/// <summary> Retrieves the related entity of type 'TeamEntity', using a relation of type 'n:1'</summary>
		/// <param name="forceFetch">if true, it will discard any changes currently in the currently loaded related entity and will refetch the entity from the persistent storage</param>
		/// <returns>A fetched entity of type 'TeamEntity' which is related to this entity.</returns>
		public virtual TeamEntity GetSingleTeam_(bool forceFetch)
		{
 			if( ( !_alreadyFetchedTeam_ || forceFetch || _alwaysFetchTeam_) && !base.IsSerializing && !base.IsDeserializing )
			{

				TeamEntity newEntity = new TeamEntity();
				if(base.ParticipatesInTransaction)
				{
					base.Transaction.Add(newEntity);
				}
				bool fetchResult = newEntity.FetchUsingPK(this.AwayTeamID);
				if(!_team_ReturnsNewIfNotFound && !fetchResult)
				{
					this.Team_ = null;
				}
				else
				{
					if((base.ActiveContext!=null)&&fetchResult)
					{
						newEntity = (TeamEntity)base.ActiveContext.Get(newEntity);
					}
					this.Team_ = newEntity;
					_alreadyFetchedTeam_ = fetchResult;
				}
				if(base.ParticipatesInTransaction && !fetchResult)
				{
					base.Transaction.Remove(newEntity);
				}
			}
			return _team_;
		}

	
		#region Data binding change event raising methods

		/// <summary> Event thrower for the GameIDChanged event, which is thrown when GameID changes value. Databinding related.</summary>
		protected virtual void OnGameIDChanged()
		{
			if(GameIDChanged!=null)
			{
				GameIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the LeagueIDChanged event, which is thrown when LeagueID changes value. Databinding related.</summary>
		protected virtual void OnLeagueIDChanged()
		{
			if(LeagueIDChanged!=null)
			{
				LeagueIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the FieldIDChanged event, which is thrown when FieldID changes value. Databinding related.</summary>
		protected virtual void OnFieldIDChanged()
		{
			if(FieldIDChanged!=null)
			{
				FieldIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the GameDayChanged event, which is thrown when GameDay changes value. Databinding related.</summary>
		protected virtual void OnGameDayChanged()
		{
			if(GameDayChanged!=null)
			{
				GameDayChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the HomeTeamIDChanged event, which is thrown when HomeTeamID changes value. Databinding related.</summary>
		protected virtual void OnHomeTeamIDChanged()
		{
			if(HomeTeamIDChanged!=null)
			{
				HomeTeamIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the AwayTeamIDChanged event, which is thrown when AwayTeamID changes value. Databinding related.</summary>
		protected virtual void OnAwayTeamIDChanged()
		{
			if(AwayTeamIDChanged!=null)
			{
				AwayTeamIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the HomeHomeScoreChanged event, which is thrown when HomeHomeScore changes value. Databinding related.</summary>
		protected virtual void OnHomeHomeScoreChanged()
		{
			if(HomeHomeScoreChanged!=null)
			{
				HomeHomeScoreChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the HomeAwayScoreChanged event, which is thrown when HomeAwayScore changes value. Databinding related.</summary>
		protected virtual void OnHomeAwayScoreChanged()
		{
			if(HomeAwayScoreChanged!=null)
			{
				HomeAwayScoreChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the AwayHomeScoreChanged event, which is thrown when AwayHomeScore changes value. Databinding related.</summary>
		protected virtual void OnAwayHomeScoreChanged()
		{
			if(AwayHomeScoreChanged!=null)
			{
				AwayHomeScoreChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the AwayAwayScoreChanged event, which is thrown when AwayAwayScore changes value. Databinding related.</summary>
		protected virtual void OnAwayAwayScoreChanged()
		{
			if(AwayAwayScoreChanged!=null)
			{
				AwayAwayScoreChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the HomeSpiritScoreChanged event, which is thrown when HomeSpiritScore changes value. Databinding related.</summary>
		protected virtual void OnHomeSpiritScoreChanged()
		{
			if(HomeSpiritScoreChanged!=null)
			{
				HomeSpiritScoreChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the AwaySpiritScoreChanged event, which is thrown when AwaySpiritScore changes value. Databinding related.</summary>
		protected virtual void OnAwaySpiritScoreChanged()
		{
			if(AwaySpiritScoreChanged!=null)
			{
				AwaySpiritScoreChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the HomeWharmbyPlayerIDChanged event, which is thrown when HomeWharmbyPlayerID changes value. Databinding related.</summary>
		protected virtual void OnHomeWharmbyPlayerIDChanged()
		{
			if(HomeWharmbyPlayerIDChanged!=null)
			{
				HomeWharmbyPlayerIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the AwayWharmbyPlayerIDChanged event, which is thrown when AwayWharmbyPlayerID changes value. Databinding related.</summary>
		protected virtual void OnAwayWharmbyPlayerIDChanged()
		{
			if(AwayWharmbyPlayerIDChanged!=null)
			{
				AwayWharmbyPlayerIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the DescriptionChanged event, which is thrown when Description changes value. Databinding related.</summary>
		protected virtual void OnDescriptionChanged()
		{
			if(DescriptionChanged!=null)
			{
				DescriptionChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the EnteredByIDChanged event, which is thrown when EnteredByID changes value. Databinding related.</summary>
		protected virtual void OnEnteredByIDChanged()
		{
			if(EnteredByIDChanged!=null)
			{
				EnteredByIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the ChangedByIDChanged event, which is thrown when ChangedByID changes value. Databinding related.</summary>
		protected virtual void OnChangedByIDChanged()
		{
			if(ChangedByIDChanged!=null)
			{
				ChangedByIDChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the GameTimeChanged event, which is thrown when GameTime changes value. Databinding related.</summary>
		protected virtual void OnGameTimeChanged()
		{
			if(GameTimeChanged!=null)
			{
				GameTimeChanged(this, new EventArgs());
			}
		}

		/// <summary> Event thrower for the GroupingChanged event, which is thrown when Grouping changes value. Databinding related.</summary>
		protected virtual void OnGroupingChanged()
		{
			if(GroupingChanged!=null)
			{
				GroupingChanged(this, new EventArgs());
			}
		}

		#endregion
		
		/// <summary> Sets the field on index fieldIndex to the new value value. Marks also the fields object as dirty. </summary>
		/// <param name="fieldIndex">Index of field to set the new value of</param>
		/// <param name="value">Value to set</param>
		/// <param name="checkForRefetch">If set to true, it will check if this entity is out of sync and will refetch it first if it is. Use true in normal behavior, false for framework specific code.</param>
		/// <returns>true if the value is actually set, false otherwise.</returns>
		/// <remarks>Dereferences a related object in an 1:1/m:1 relation if the field is an FK field and responsible for the reference of that particular related object.</remarks>
		/// <exception cref="ArgumentOutOfRangeException">When fieldIndex is smaller than 0 or bigger than the number of fields in the fields collection.</exception>
		protected override bool SetNewFieldValue(int fieldIndex, object value, bool checkForRefetch)
		{
			bool toReturn = base.SetNewFieldValue (fieldIndex, value, checkForRefetch, false);
			if(toReturn)
			{
				switch((GameFieldIndex)fieldIndex)
				{
					case GameFieldIndex.LeagueID:
						DecoupleEventsLeague();
						_league = null;
						_alreadyFetchedLeague = false;
						break;
					case GameFieldIndex.FieldID:
						DecoupleEventsField();
						_field = null;
						_alreadyFetchedField = false;
						break;
					case GameFieldIndex.HomeTeamID:
						DecoupleEventsTeam();
						_team = null;
						_alreadyFetchedTeam = false;
						break;
					case GameFieldIndex.AwayTeamID:
						DecoupleEventsTeam_();
						_team_ = null;
						_alreadyFetchedTeam_ = false;
						break;
					default:
						break;
				}
				base.PostFieldValueSetAction(toReturn);
				switch((GameFieldIndex)fieldIndex)
				{
					case GameFieldIndex.GameID:
						OnGameIDChanged();
						break;
					case GameFieldIndex.LeagueID:
						OnLeagueIDChanged();
						break;
					case GameFieldIndex.FieldID:
						OnFieldIDChanged();
						break;
					case GameFieldIndex.GameDay:
						OnGameDayChanged();
						break;
					case GameFieldIndex.HomeTeamID:
						OnHomeTeamIDChanged();
						break;
					case GameFieldIndex.AwayTeamID:
						OnAwayTeamIDChanged();
						break;
					case GameFieldIndex.HomeHomeScore:
						OnHomeHomeScoreChanged();
						break;
					case GameFieldIndex.HomeAwayScore:
						OnHomeAwayScoreChanged();
						break;
					case GameFieldIndex.AwayHomeScore:
						OnAwayHomeScoreChanged();
						break;
					case GameFieldIndex.AwayAwayScore:
						OnAwayAwayScoreChanged();
						break;
					case GameFieldIndex.HomeSpiritScore:
						OnHomeSpiritScoreChanged();
						break;
					case GameFieldIndex.AwaySpiritScore:
						OnAwaySpiritScoreChanged();
						break;
					case GameFieldIndex.HomeWharmbyPlayerID:
						OnHomeWharmbyPlayerIDChanged();
						break;
					case GameFieldIndex.AwayWharmbyPlayerID:
						OnAwayWharmbyPlayerIDChanged();
						break;
					case GameFieldIndex.Description:
						OnDescriptionChanged();
						break;
					case GameFieldIndex.EnteredByID:
						OnEnteredByIDChanged();
						break;
					case GameFieldIndex.ChangedByID:
						OnChangedByIDChanged();
						break;
					case GameFieldIndex.GameTime:
						OnGameTimeChanged();
						break;
					case GameFieldIndex.Grouping:
						OnGroupingChanged();
						break;
					default:
						break;
				}
			}
			return toReturn;
		}

		/// <summary> Performs the insert action of a new Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool InsertEntity()
		{
			GameDAO dao = (GameDAO)CreateDAOInstance();
			return dao.AddNew(base.Fields, base.Transaction);
		}
		
		/// <summary> Adds the internals to the active context. </summary>
		protected override void AddInternalsToContext()
		{


			if(_field!=null)
			{
				_field.ActiveContext = base.ActiveContext;
			}
			if(_league!=null)
			{
				_league.ActiveContext = base.ActiveContext;
			}
			if(_team!=null)
			{
				_team.ActiveContext = base.ActiveContext;
			}
			if(_team_!=null)
			{
				_team_.ActiveContext = base.ActiveContext;
			}


		}


		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity()
		{
			GameDAO dao = (GameDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction);
		}
		
		/// <summary> Performs the update action of an existing Entity to the persistent storage.</summary>
		/// <param name="updateRestriction">Predicate expression, meant for concurrency checks in an Update query</param>
		/// <returns>true if succeeded, false otherwise</returns>
		protected override bool UpdateEntity(IPredicate updateRestriction)
		{
			GameDAO dao = (GameDAO)CreateDAOInstance();
			return dao.UpdateExisting(base.Fields, base.Transaction, updateRestriction);
		}
	
		/// <summary> Initializes the class with empty data, as if it is a new Entity.</summary>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		/// <param name="validatorToUse">Validator to use.</param>
		protected virtual void InitClassEmpty(IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse, IValidator validatorToUse)
		{
			base.Fields = CreateFields();
			base.IsNew=true;
			base.EntityFactoryToUse = entityFactoryToUse;
			base.Validator = validatorToUse;

			InitClassMembers(propertyDescriptorFactoryToUse, entityFactoryToUse);
			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
			// __LLBLGENPRO_USER_CODE_REGION_END

		}

		/// <summary> A method which calls all OnFieldnameChanged methods to signal that the field has been changed
		/// to bound controls. This is required after a RollbackFields() call.</summary>
		protected override void FlagAllFieldsAsChanged()
		{
			OnGameIDChanged();
			OnLeagueIDChanged();
			OnFieldIDChanged();
			OnGameDayChanged();
			OnHomeTeamIDChanged();
			OnAwayTeamIDChanged();
			OnHomeHomeScoreChanged();
			OnHomeAwayScoreChanged();
			OnAwayHomeScoreChanged();
			OnAwayAwayScoreChanged();
			OnHomeSpiritScoreChanged();
			OnAwaySpiritScoreChanged();
			OnHomeWharmbyPlayerIDChanged();
			OnAwayWharmbyPlayerIDChanged();
			OnDescriptionChanged();
			OnEnteredByIDChanged();
			OnChangedByIDChanged();
			OnGameTimeChanged();
			OnGroupingChanged();
		}
		
		/// <summary>Creates entity fields object for this entity. Used in constructor to setup this entity in a polymorphic scenario.</summary>
		protected virtual IEntityFields CreateFields()
		{
			return EntityFieldsFactory.CreateEntityFieldsObject(Ultimate.DAL.EntityType.GameEntity);
		}

		/// <summary>Creates field validator object for this entity. Used in constructor to setup this entity in a polymorphic scenario.</summary>
		protected virtual IValidator CreateValidator()
		{
			return new GameValidator();
		}


		/// <summary> Initializes the the entity and fetches the data related to the entity in this entity.</summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		/// <param name="validator">The validator object for this GameEntity</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		protected virtual void InitClassFetch(System.Int32 gameID, IValidator validator, IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse, IPrefetchPath prefetchPathToUse)
		{
			InitClassMembers(propertyDescriptorFactoryToUse, entityFactoryToUse);

			base.Fields = CreateFields();
			bool wasSuccesful = Fetch(gameID, prefetchPathToUse, null);
			base.IsNew = !wasSuccesful;
			base.Validator = validator;
			base.EntityFactoryToUse = entityFactoryToUse;

			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassFetch
			// __LLBLGENPRO_USER_CODE_REGION_END

		}

		/// <summary> Initializes the class members</summary>
		/// <param name="propertyDescriptorFactoryToUse">PropertyDescriptor factory to use in GetItemProperties method of contained collections. Complex databinding related.</param>
		/// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
		private void InitClassMembers(IPropertyDescriptorFactory propertyDescriptorFactoryToUse, IEntityFactory entityFactoryToUse)
		{


			_field = null;
			_fieldReturnsNewIfNotFound = true;
			_alwaysFetchField = false;
			_alreadyFetchedField = false;
			_league = null;
			_leagueReturnsNewIfNotFound = true;
			_alwaysFetchLeague = false;
			_alreadyFetchedLeague = false;
			_team = null;
			_teamReturnsNewIfNotFound = true;
			_alwaysFetchTeam = false;
			_alreadyFetchedTeam = false;
			_team_ = null;
			_team_ReturnsNewIfNotFound = true;
			_alwaysFetchTeam_ = false;
			_alreadyFetchedTeam_ = false;

			
			// __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
			// __LLBLGENPRO_USER_CODE_REGION_END
		}

		#region Custom Property Hashtable Setup
		/// <summary> Initializes the hashtables for the entity type and entity field custom properties. </summary>
		private static void SetupCustomPropertyHashtables()
		{
			_customProperties = new Hashtable();
			_fieldsCustomProperties = new Hashtable();

			Hashtable fieldHashtable = null;
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("GameID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("LeagueID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("FieldID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("GameDay", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("HomeTeamID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("AwayTeamID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("HomeHomeScore", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("HomeAwayScore", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("AwayHomeScore", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("AwayAwayScore", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("HomeSpiritScore", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("AwaySpiritScore", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("HomeWharmbyPlayerID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("AwayWharmbyPlayerID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("Description", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("EnteredByID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("ChangedByID", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("GameTime", fieldHashtable);
			fieldHashtable = new Hashtable();

			_fieldsCustomProperties.Add("Grouping", fieldHashtable);
		}
		#endregion


		/// <summary> Removes the sync logic for member _field</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		private void DesetupSyncField(bool signalRelatedEntity)
		{
			if(_field != null)
			{

				_field.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("Field", _field, GameEntity.Relations.FieldEntityUsingFieldID);
				if(signalRelatedEntity)
				{
					_field.UnsetRelatedEntity(this, "Game");
				}
				SetNewFieldValue((int)GameFieldIndex.FieldID, null, false);
				_field = null;
			}
		}
		
		/// <summary> Decouples events from member _field</summary>
		private void DecoupleEventsField()
		{
			if(_field != null)
			{

				
				_field.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("Field", _field, GameEntity.Relations.FieldEntityUsingFieldID);
			}
		}
		
		/// <summary> setups the sync logic for member _field</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncField(IEntity relatedEntity)
		{
			DesetupSyncField(true);
			if(relatedEntity!=null)
			{
				_field = (FieldEntity)relatedEntity;
				_field.ActiveContext = base.ActiveContext;
				_alreadyFetchedField = true;
				_field.AfterSave+=new EventHandler(OnEntityAfterSave);
				base.SetEntitySyncInformation("Field", _field, GameEntity.Relations.FieldEntityUsingFieldID);

			}
			else
			{
				_alreadyFetchedField = false;
			}
		}

		/// <summary> Removes the sync logic for member _league</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		private void DesetupSyncLeague(bool signalRelatedEntity)
		{
			if(_league != null)
			{

				_league.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("League", _league, GameEntity.Relations.LeagueEntityUsingLeagueID);
				if(signalRelatedEntity)
				{
					_league.UnsetRelatedEntity(this, "Game");
				}
				SetNewFieldValue((int)GameFieldIndex.LeagueID, null, false);
				_league = null;
			}
		}
		
		/// <summary> Decouples events from member _league</summary>
		private void DecoupleEventsLeague()
		{
			if(_league != null)
			{

				
				_league.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("League", _league, GameEntity.Relations.LeagueEntityUsingLeagueID);
			}
		}
		
		/// <summary> setups the sync logic for member _league</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncLeague(IEntity relatedEntity)
		{
			DesetupSyncLeague(true);
			if(relatedEntity!=null)
			{
				_league = (LeagueEntity)relatedEntity;
				_league.ActiveContext = base.ActiveContext;
				_alreadyFetchedLeague = true;
				_league.AfterSave+=new EventHandler(OnEntityAfterSave);
				base.SetEntitySyncInformation("League", _league, GameEntity.Relations.LeagueEntityUsingLeagueID);

			}
			else
			{
				_alreadyFetchedLeague = false;
			}
		}

		/// <summary> Removes the sync logic for member _team</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		private void DesetupSyncTeam(bool signalRelatedEntity)
		{
			if(_team != null)
			{

				_team.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("Team", _team, GameEntity.Relations.TeamEntityUsingHomeTeamID);
				if(signalRelatedEntity)
				{
					_team.UnsetRelatedEntity(this, "Game");
				}
				SetNewFieldValue((int)GameFieldIndex.HomeTeamID, null, false);
				_team = null;
			}
		}
		
		/// <summary> Decouples events from member _team</summary>
		private void DecoupleEventsTeam()
		{
			if(_team != null)
			{

				
				_team.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("Team", _team, GameEntity.Relations.TeamEntityUsingHomeTeamID);
			}
		}
		
		/// <summary> setups the sync logic for member _team</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncTeam(IEntity relatedEntity)
		{
			DesetupSyncTeam(true);
			if(relatedEntity!=null)
			{
				_team = (TeamEntity)relatedEntity;
				_team.ActiveContext = base.ActiveContext;
				_alreadyFetchedTeam = true;
				_team.AfterSave+=new EventHandler(OnEntityAfterSave);
				base.SetEntitySyncInformation("Team", _team, GameEntity.Relations.TeamEntityUsingHomeTeamID);

			}
			else
			{
				_alreadyFetchedTeam = false;
			}
		}

		/// <summary> Removes the sync logic for member _team_</summary>
		/// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
		private void DesetupSyncTeam_(bool signalRelatedEntity)
		{
			if(_team_ != null)
			{

				_team_.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("Team_", _team_, GameEntity.Relations.TeamEntityUsingAwayTeamID);
				if(signalRelatedEntity)
				{
					_team_.UnsetRelatedEntity(this, "Game_");
				}
				SetNewFieldValue((int)GameFieldIndex.AwayTeamID, null, false);
				_team_ = null;
			}
		}
		
		/// <summary> Decouples events from member _team_</summary>
		private void DecoupleEventsTeam_()
		{
			if(_team_ != null)
			{

				
				_team_.AfterSave-=new EventHandler(OnEntityAfterSave);
				base.UnsetEntitySyncInformation("Team_", _team_, GameEntity.Relations.TeamEntityUsingAwayTeamID);
			}
		}
		
		/// <summary> setups the sync logic for member _team_</summary>
		/// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
		private void SetupSyncTeam_(IEntity relatedEntity)
		{
			DesetupSyncTeam_(true);
			if(relatedEntity!=null)
			{
				_team_ = (TeamEntity)relatedEntity;
				_team_.ActiveContext = base.ActiveContext;
				_alreadyFetchedTeam_ = true;
				_team_.AfterSave+=new EventHandler(OnEntityAfterSave);
				base.SetEntitySyncInformation("Team_", _team_, GameEntity.Relations.TeamEntityUsingAwayTeamID);

			}
			else
			{
				_alreadyFetchedTeam_ = false;
			}
		}


		/// <summary> Fetches the entity from the persistent storage. Fetch simply reads the entity into an EntityFields object. </summary>
		/// <param name="gameID">PK value for Game which data should be fetched into this Game object</param>
		/// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch as well</param>
		/// <param name="contextToUse">The context to add the entity to if the fetch was succesful. </param>
		/// <returns>True if succeeded, false otherwise.</returns>
		private bool Fetch(System.Int32 gameID, IPrefetchPath prefetchPathToUse, Context contextToUse)
		{
			try
			{
				OnFetch();
				IDao dao = this.CreateDAOInstance();
				base.Fields[(int)GameFieldIndex.GameID].ForcedCurrentValueWrite(gameID);
				dao.FetchExisting(this, base.Transaction, prefetchPathToUse, contextToUse);
				bool fetchResult = false;
				if(base.Fields.State == EntityState.Fetched)
				{
					base.IsNew = false;
					fetchResult = true;
					if(contextToUse!=null)
					{
						base.ActiveContext = contextToUse;
						IEntity dummy = contextToUse.Get(this);
					}
				}
				return fetchResult;
			}
			finally
			{
				OnFetchComplete();
			}
		}


		/// <summary> Creates the DAO instance for this type</summary>
		/// <returns></returns>
		protected override IDao CreateDAOInstance()
		{
			return DAOFactory.CreateGameDAO();
		}
		
		/// <summary> Creates the entity factory for this type.</summary>
		/// <returns></returns>
		protected override IEntityFactory CreateEntityFactoryInstance()
		{
			return new GameEntityFactory();
		}

		#region Class Property Declarations
		/// <summary> The relations object holding all relations of this entity with other entity classes.</summary>
		public  static GameRelations Relations
		{
			get	{ return new GameRelations(); }
		}
		
		/// <summary> The custom properties for this entity type.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Hashtable CustomProperties
		{
			get { return _customProperties;}
		}




		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Field' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathField
		{
			get
			{
				return new PrefetchPathElement(new Ultimate.DAL.CollectionClasses.FieldCollection(),
					GameEntity.Relations.FieldEntityUsingFieldID, 
					(int)Ultimate.DAL.EntityType.GameEntity, (int)Ultimate.DAL.EntityType.FieldEntity, 0, null, null, null, "Field", RelationType.ManyToOne);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'League' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathLeague
		{
			get
			{
				return new PrefetchPathElement(new Ultimate.DAL.CollectionClasses.LeagueCollection(),
					GameEntity.Relations.LeagueEntityUsingLeagueID, 
					(int)Ultimate.DAL.EntityType.GameEntity, (int)Ultimate.DAL.EntityType.LeagueEntity, 0, null, null, null, "League", RelationType.ManyToOne);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Team' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathTeam
		{
			get
			{
				return new PrefetchPathElement(new Ultimate.DAL.CollectionClasses.TeamCollection(),
					GameEntity.Relations.TeamEntityUsingHomeTeamID, 
					(int)Ultimate.DAL.EntityType.GameEntity, (int)Ultimate.DAL.EntityType.TeamEntity, 0, null, null, null, "Team", RelationType.ManyToOne);
			}
		}

		/// <summary> Creates a new PrefetchPathElement object which contains all the information to prefetch the related entities of type 'Team' 
		/// for this entity. Add the object returned by this property to an existing PrefetchPath instance.</summary>
		/// <returns>Ready to use IPrefetchPathElement implementation.</returns>
		public static IPrefetchPathElement PrefetchPathTeam_
		{
			get
			{
				return new PrefetchPathElement(new Ultimate.DAL.CollectionClasses.TeamCollection(),
					GameEntity.Relations.TeamEntityUsingAwayTeamID, 
					(int)Ultimate.DAL.EntityType.GameEntity, (int)Ultimate.DAL.EntityType.TeamEntity, 0, null, null, null, "Team_", RelationType.ManyToOne);
			}
		}


		/// <summary> The custom properties for the type of this entity instance.</summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public virtual Hashtable CustomPropertiesOfType
		{
			get { return GameEntity.CustomProperties;}
		}

		/// <summary> The custom properties for the fields of this entity type. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		public  static Hashtable FieldsCustomProperties
		{
			get { return _fieldsCustomProperties;}
		}

		/// <summary> The custom properties for the fields of the type of this entity instance. The returned Hashtable contains per fieldname a hashtable of name-value pairs. </summary>
		/// <remarks>The data returned from this property should be considered read-only: it is not thread safe to alter this data at runtime.</remarks>
		[Browsable(false), XmlIgnore]
		public virtual Hashtable FieldsCustomPropertiesOfType
		{
			get { return GameEntity.FieldsCustomProperties;}
		}

		/// <summary> The GameID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."GameID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): false, true, true</remarks>
		public virtual System.Int32 GameID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.GameID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.GameID, value); }
		}
		/// <summary> The LeagueID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."LeagueID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 LeagueID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.LeagueID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.LeagueID, value); }
		}
		/// <summary> The FieldID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."FieldID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 FieldID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.FieldID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.FieldID, value); }
		}
		/// <summary> The GameDay property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."GameDay"<br/>
		/// Table field type characteristics (type, precision, scale, length): SmallDateTime, 0, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.DateTime GameDay
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.GameDay);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.DateTime));
				}
				return (System.DateTime)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.GameDay, value); }
		}
		/// <summary> The HomeTeamID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."HomeTeamID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 HomeTeamID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.HomeTeamID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.HomeTeamID, value); }
		}
		/// <summary> The AwayTeamID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."AwayTeamID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 AwayTeamID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.AwayTeamID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.AwayTeamID, value); }
		}
		/// <summary> The HomeHomeScore property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."HomeHomeScore"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 HomeHomeScore
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.HomeHomeScore);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.HomeHomeScore, value); }
		}
		/// <summary> The HomeAwayScore property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."HomeAwayScore"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 HomeAwayScore
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.HomeAwayScore);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.HomeAwayScore, value); }
		}
		/// <summary> The AwayHomeScore property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."AwayHomeScore"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 AwayHomeScore
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.AwayHomeScore);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.AwayHomeScore, value); }
		}
		/// <summary> The AwayAwayScore property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."AwayAwayScore"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 AwayAwayScore
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.AwayAwayScore);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.AwayAwayScore, value); }
		}
		/// <summary> The HomeSpiritScore property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."HomeSpiritScore"<br/>
		/// Table field type characteristics (type, precision, scale, length): Float, 38, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Double HomeSpiritScore
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.HomeSpiritScore);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Double));
				}
				return (System.Double)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.HomeSpiritScore, value); }
		}
		/// <summary> The AwaySpiritScore property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."AwaySpiritScore"<br/>
		/// Table field type characteristics (type, precision, scale, length): Float, 38, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Double AwaySpiritScore
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.AwaySpiritScore);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Double));
				}
				return (System.Double)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.AwaySpiritScore, value); }
		}
		/// <summary> The HomeWharmbyPlayerID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."HomeWharmbyPlayerID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 HomeWharmbyPlayerID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.HomeWharmbyPlayerID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.HomeWharmbyPlayerID, value); }
		}
		/// <summary> The AwayWharmbyPlayerID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."AwayWharmbyPlayerID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 AwayWharmbyPlayerID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.AwayWharmbyPlayerID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.AwayWharmbyPlayerID, value); }
		}
		/// <summary> The Description property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."Description"<br/>
		/// Table field type characteristics (type, precision, scale, length): NText, 0, 0, 1073741823<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String Description
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.Description);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.Description, value); }
		}
		/// <summary> The EnteredByID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."EnteredByID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 EnteredByID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.EnteredByID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.EnteredByID, value); }
		}
		/// <summary> The ChangedByID property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."ChangedByID"<br/>
		/// Table field type characteristics (type, precision, scale, length): Int, 10, 0, 0<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.Int32 ChangedByID
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.ChangedByID);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.Int32));
				}
				return (System.Int32)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.ChangedByID, value); }
		}
		/// <summary> The GameTime property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."GameTime"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 5<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String GameTime
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.GameTime);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.GameTime, value); }
		}
		/// <summary> The Grouping property of the Entity Game<br/><br/>
		/// </summary>
		/// <remarks>Mapped on  table field: "Game"."Grouping"<br/>
		/// Table field type characteristics (type, precision, scale, length): NVarChar, 0, 0, 64<br/>
		/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
		public virtual System.String Grouping
		{
			get
			{
				object valueToReturn = base.GetCurrentFieldValue((int)GameFieldIndex.Grouping);
				if(valueToReturn == null)
				{
					valueToReturn = TypeDefaultValue.GetDefaultValue(typeof(System.String));
				}
				return (System.String)valueToReturn;
			}
			set	{ SetNewFieldValue((int)GameFieldIndex.Grouping, value); }
		}



		/// <summary> Gets / sets related entity of type 'FieldEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleField()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual FieldEntity Field
		{
			get	{ return GetSingleField(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncField(value);
				}
				else
				{
					if(value==null)
					{
						if(_field != null)
						{
							_field.UnsetRelatedEntity(this, "Game");
						}
					}
					else
					{
						((IEntity)value).SetRelatedEntity(this, "Game");
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for Field. When set to true, Field is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time Field is accessed. You can always execute
		/// a forced fetch by calling GetSingleField(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchField
		{
			get	{ return _alwaysFetchField; }
			set	{ _alwaysFetchField = value; }	
		}
		
		/// <summary> Gets / sets the flag for what to do if the related entity available through the property Field is not found
		/// in the database. When set to true, Field will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool FieldReturnsNewIfNotFound
		{
			get	{ return _fieldReturnsNewIfNotFound; }
			set { _fieldReturnsNewIfNotFound = value; }	
		}
		/// <summary> Gets / sets related entity of type 'LeagueEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleLeague()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual LeagueEntity League
		{
			get	{ return GetSingleLeague(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncLeague(value);
				}
				else
				{
					if(value==null)
					{
						if(_league != null)
						{
							_league.UnsetRelatedEntity(this, "Game");
						}
					}
					else
					{
						((IEntity)value).SetRelatedEntity(this, "Game");
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for League. When set to true, League is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time League is accessed. You can always execute
		/// a forced fetch by calling GetSingleLeague(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchLeague
		{
			get	{ return _alwaysFetchLeague; }
			set	{ _alwaysFetchLeague = value; }	
		}
		
		/// <summary> Gets / sets the flag for what to do if the related entity available through the property League is not found
		/// in the database. When set to true, League will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool LeagueReturnsNewIfNotFound
		{
			get	{ return _leagueReturnsNewIfNotFound; }
			set { _leagueReturnsNewIfNotFound = value; }	
		}
		/// <summary> Gets / sets related entity of type 'TeamEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleTeam()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual TeamEntity Team
		{
			get	{ return GetSingleTeam(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncTeam(value);
				}
				else
				{
					if(value==null)
					{
						if(_team != null)
						{
							_team.UnsetRelatedEntity(this, "Game");
						}
					}
					else
					{
						((IEntity)value).SetRelatedEntity(this, "Game");
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for Team. When set to true, Team is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time Team is accessed. You can always execute
		/// a forced fetch by calling GetSingleTeam(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchTeam
		{
			get	{ return _alwaysFetchTeam; }
			set	{ _alwaysFetchTeam = value; }	
		}
		
		/// <summary> Gets / sets the flag for what to do if the related entity available through the property Team is not found
		/// in the database. When set to true, Team will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool TeamReturnsNewIfNotFound
		{
			get	{ return _teamReturnsNewIfNotFound; }
			set { _teamReturnsNewIfNotFound = value; }	
		}
		/// <summary> Gets / sets related entity of type 'TeamEntity'. This property is not visible in databound grids.
		/// Setting this property to a new object will make the load-on-demand feature to stop fetching data from the database, until you set this
		/// property to null. Setting this property to an entity will make sure that FK-PK relations are synchronized when appropriate.</summary>
		/// <remarks>This property is added for conveniance, however it is recommeded to use the method 'GetSingleTeam_()', because 
		/// this property is rather expensive and a method tells the user to cache the result when it has to be used more than once in the
		/// same scope. The property is marked non-browsable to make it hidden in bound controls, f.e. datagrids.</remarks>
		[Browsable(false)]
		public virtual TeamEntity Team_
		{
			get	{ return GetSingleTeam_(false); }
			set
			{
				if(base.IsDeserializing)
				{
					SetupSyncTeam_(value);
				}
				else
				{
					if(value==null)
					{
						if(_team_ != null)
						{
							_team_.UnsetRelatedEntity(this, "Game_");
						}
					}
					else
					{
						((IEntity)value).SetRelatedEntity(this, "Game_");
					}
				}
			}
		}

		/// <summary> Gets / sets the lazy loading flag for Team_. When set to true, Team_ is always refetched from the 
		/// persistent storage. When set to false, the data is only fetched the first time Team_ is accessed. You can always execute
		/// a forced fetch by calling GetSingleTeam_(true).</summary>
		[Browsable(false)]
		public bool AlwaysFetchTeam_
		{
			get	{ return _alwaysFetchTeam_; }
			set	{ _alwaysFetchTeam_ = value; }	
		}
		
		/// <summary> Gets / sets the flag for what to do if the related entity available through the property Team_ is not found
		/// in the database. When set to true, Team_ will return a new entity instance if the related entity is not found, otherwise 
		/// null be returned if the related entity is not found. Default: true.</summary>
		[Browsable(false)]
		public bool Team_ReturnsNewIfNotFound
		{
			get	{ return _team_ReturnsNewIfNotFound; }
			set { _team_ReturnsNewIfNotFound = value; }	
		}



		/// <summary> Gets or sets a value indicating whether this entity is a subtype</summary>
		protected override bool LLBLGenProIsSubType
		{
			get { return false;}
		}

		/// <summary> Gets the type of the hierarchy this entity is in. </summary>
		[System.ComponentModel.Browsable(false), XmlIgnore]
		protected override InheritanceHierarchyType LLBLGenProIsInHierarchyOfType
		{
			get { return InheritanceHierarchyType.None;}
		}
		
		/// <summary>Returns the EntityType enum value for this entity.</summary>
		[Browsable(false), XmlIgnore]
		public override int LLBLGenProEntityTypeValue 
		{ 
			get { return (int)Ultimate.DAL.EntityType.GameEntity; }
		}
		#endregion

		
		#region Custom Entity code
		
		// __LLBLGENPRO_USER_CODE_REGION_START CustomEntityCode
		// __LLBLGENPRO_USER_CODE_REGION_END
		#endregion

		#region Included code

		#endregion
	}
}
